import java.util.ArrayList;
import java.util.List;

/**
 * Created by wangxingsheng on 2019/6/27.
 */
public class ListArrayTest {
    public static void main(String[] args) {
        System.out.println("out");

        List<Demo> demoList = new ArrayList<>();
        demoList.add(new Demo("a", 1));
        demoList.add(new Demo("b", 2));
        Demo[] array = demoList.toArray(new Demo[0]);
        pf(array);
    }

    private static void pf(Demo[] array) {
        for (Demo arrayItem : array) {
            System.out.print(arrayItem + " ");
        }
    }

    private static class Demo {
        private String name;
        private int age;

        public Demo(String name, int age) {
            this.name = name;
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        @Override
        public String toString() {
            return "Demo{" +
                    "name='" + name + '\'' +
                    ", age=" + age +
                    '}';
        }
    }
}
